import java.io.*;
import javax.swing.tree.DefaultMutableTreeNode;


/**
 * EBook Organizer
 * 5/26/2010
 * <P>
 * Contains relavant information to an actual <code>EBook</code>.
 * </P>
 * @version 0.2
 */
public class EBook extends DefaultMutableTreeNode implements java.io.Serializable, Comparable<EBook> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4549926370029992171L;
	String name;
	File file;
	EBookAttributes attributes;
	
	public EBook(File file, FileType type) {
		super();
		this.file = file;
		
		//TODO figure out name
		if (file!=null)
			name = file.getName();
		else {
			name = "DefaultBookName";
			System.out.println("EBook Constructor: null file");
		}
			
		
		attributes = new EBookAttributes(type);
	}
	
	public String getName() { return name; };
	
	public String getFilePath() {
		return file.getPath();
	}
	
	public String toString() {
		return this.getName();
	}
	
	public int compareTo(EBook book) {
		return this.getName().compareToIgnoreCase( book.getName() );
	}
	
	public EBookAttributes getAttributes() {
		return attributes;
	}
	
	public String toOpenString() {
		return attributes.type.toOpenString( this );
	}

}
